cmake_minimum_required(VERSION 3.5)
project(lidar209_driver)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake_ros REQUIRED)
find_package(diagnostic_msgs REQUIRED)
find_package(diagnostic_updater REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(lidar209_msgs REQUIRED)

# libpcap provides no pkg-config or find_package module:
set(libpcap_LIBRARIES -lpcap)

include_directories(
include
${lidar209_msgs_INCLUDE_DIRS}
)

# compile the driver and input library
add_subdirectory(src)

# build the driver node
add_library(lidar209_driver SHARED src/driver.cc)
ament_target_dependencies(lidar209_driver
  diagnostic_msgs
  diagnostic_updater
  rclcpp
  rclcpp_components
  tf2_ros
  lidar209_msgs
)
target_link_libraries(lidar209_driver lidar209_input)

add_executable(lidar209_driver_node src/lidar209_node.cc)
ament_target_dependencies(lidar209_driver_node
  rclcpp
)
target_link_libraries(lidar209_driver_node lidar209_driver)

# install runtime and library files
install(TARGETS lidar209_driver
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
)
install(TARGETS lidar209_driver_node
  DESTINATION lib/${PROJECT_NAME}
)

rclcpp_components_register_nodes(lidar209_driver
  "lidar209_driver::lidar209Driver")


install(DIRECTORY config launch
  DESTINATION share/${PROJECT_NAME})

ament_package()


